A meal delivery company which operates in multiple cities. It have various fulfillment centers in these cities for dispatching meal orders to their customers. My goal is to help these centers with demand forecasting for upcoming weeks so that these centers will plan the stock of raw materials accordingly.
Objective
The replenishment of majority of raw materials is done on weekly basis and since the raw material is perishable, the procurement planning is of utmost importance. To predict the demand for the next 10 weeks (Weeks: 146-155) for the center-meal combinations in the test set.
Secondly, staffing of the centers is also one area wherein accurate demand forecasts are really helpful.
load the libraries to use
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.0
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tsibble)
Attaching package: 'tsibble'
The following object is masked from 'package:lubridate':
interval
The following objects are masked from 'package:base':
intersect, setdiff, union
Rows: 77 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): center_type
dbl (4): center_id, city_code, region_code, op_area
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 51 Columns: 3
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): category, cuisine
dbl (1): meal_id
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(meal_info)test <-read_csv("data/test.csv")
Rows: 32573 Columns: 8
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (8): id, week, center_id, meal_id, checkout_price, base_price, emailer_f...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(test)train <-read_csv("data/train.csv")
Rows: 456548 Columns: 9
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (9): id, week, center_id, meal_id, checkout_price, base_price, emailer_f...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
gg <- ts %>%ggplot(aes(week, num_orders, col=cm_id, group=cm_id))+geom_line(show.legend =FALSE)+labs(title ="Individual ts")shared_ts <- SharedData$new(ts)filter <-bscols(filter_select("ids", "Sales over time: Select a time series ID (remove with backspace key, navigate with arrow keys):", shared_ts, ~cm_id, multiple =TRUE),ggplotly(gg, dynamicTicks =TRUE),widths =c(12, 12))
Warning in bscols(filter_select("ids", "Sales over time: Select a time series
ID (remove with backspace key, navigate with arrow keys):", : Sum of bscol
width units is greater than 12